<template>
  <div class="toast">
    <i :class="getClass"></i>
    <span>{{ toastMsg }}</span>
    <!-- <el-alert title="成功提示的文案" type="success" center show-icon>
    </el-alert> -->
  </div>
</template>
 


<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState({
      toastMsg: (state) => state.showToast.toastMsg,
      toastType: (state) => state.showToast.toastType,
    }),
    getClass() {
      if (this.toastType == "success") {
        return "iconfont icon-toast_chenggong";
      } else if (this.toastType == "error") {
        return "iconfont icon-toast-shibai_huaban";
      } else if (this.toastType == "warning") {
        return "iconfont icon-toast-jinggao";
      }
    },
  },
};
</script>


<style lang = "less" scoped>
.toast {
  position: fixed;
  z-index: 9999;
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  border-radius: 10px;
  box-shadow: 0px 0px 3px 3px rgb(202, 195, 195);
  .iconfont {
    margin-right: 10px;
  }

  .icon-toast-shibai_huaban {
    color: red;
  }

  .icon-toast_chenggong {
    color: green;
  }

  .icon-toast-jinggao {
    color: orange;
  }
}
</style>
